package com.wt.admin.controller.sys;

import com.aizuda.easy.security.domain.Rep;
import com.wt.admin.config.aspect.annotation.LogAno;
import com.wt.admin.domain.entity.sys.SysRoleEntity;
import com.wt.admin.domain.vo.sys.SysRoleListVO;
import com.wt.admin.service.sys.SysRoleService;
import com.wt.admin.util.PageUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("role")
public class SysRoleController {

    @Resource
    private SysRoleService sysRoleService;

    @LogAno(name = "角色列表")
    @PostMapping("find")
    public Rep<SysRoleListVO> findRoles(@RequestBody PageUtil.PageDTO<SysRoleEntity> data){
        return Rep.ok(sysRoleService.find(data));
    }

    @LogAno(name = "修改或添加角色")
    @PostMapping("edit")
    public Rep<SysRoleEntity> editRole(@RequestBody SysRoleEntity data){
        return Rep.ok(sysRoleService.edit(data));
    }

    @LogAno(name = "删除角色")
    @PostMapping("del")
    public Rep<SysRoleEntity> delRole(@RequestBody SysRoleEntity data){
        return Rep.ok(sysRoleService.del(data));
    }
}
